<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增债权线索')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-clue-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">主债权人名称：</label>
            <div class="col-sm-8">
                <input name="creditorName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">主债权人联系电话：</label>
            <div class="col-sm-8">
                <input name="contactNumber" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">民事判决书（或者仲裁书、调解书）字号：</label>
            <div class="col-sm-8">
                <input name="civilJudgmentFont" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">执行法院：</label>
            <div class="col-sm-8">
                <input name="court" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">判决书标的额（未执行部分）：</label>
            <div class="col-sm-8">
                <input name="judgmentMatter" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">有偿征集债务人出资金额（或债权标的额比例）：</label>
            <div class="col-sm-8">
                <input name="rewardAmount" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">债务人姓名/组织机构名称：</label>
            <div class="col-sm-8">
                <input name="debtorName" class="form-control" type="text">
            </div>
        </div>
<!--        <div class="form-group">-->
        <!--            <label class="col-sm-3 control-label">被委托人：</label>-->
        <!--            <div class="col-sm-8">-->
        <!--                <input name="mandatary" class="form-control" type="text">-->
        <!--            </div>-->
        <!--        </div>-->
        <!--        <div class="form-group">-->
        <!--            <label class="col-sm-3 control-label">被委托人联系电话：</label>-->
        <!--            <div class="col-sm-8">-->
        <!--                <input name="mandataryPhone" class="form-control" type="text">-->
        <!--            </div>-->
        <!--        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">债务人身份证号/社会统一信用代码：</label>
            <div class="col-sm-8">
                <input name="socialCode" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">身份证/营业执照有效期：</label>
            <div class="col-sm-8">
                <input name="validityPeriod" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">债务人所在地址：</label>
            <div class="col-sm-8">
                <input name="address" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">债权人的身份证明材料：</label>
            <div class="col-sm-8">
                <input type="hidden" name="creditorProveMaterial">
                <div class="file-loading">
                    <input class="file-upload" id="creditorProveMaterial" name="file" type="file">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">债务人身份证明材料：</label>
            <div class="col-sm-8">
                <input type="hidden" name="debtorProveMaterial">
                <div class="file-loading">
                    <input class="file-upload" id="debtorProveMaterial" name="file" type="file">
                </div>
            </div>
        </div>
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label">债权人和债务人营业执照：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input type="hidden" name="licensePhoto">-->
<!--                <div class="file-loading">-->
<!--                    <input class="file-upload" id="licensePhoto" name="file" type="file">-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">民事判决书：</label>
            <div class="col-sm-8">
                <input type="hidden" name="civilJudgement">
                <div class="file-loading">
                    <input class="file-upload" id="civilJudgement" name="file" type="file">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">委托书：</label>
            <div class="col-sm-8">
                <input type="hidden" name="attorneyPower">
                <div class="file-loading">
                    <input class="file-upload" id="attorneyPower" name="file" type="file">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">承诺书：</label>
            <div class="col-sm-8">
                <input type="hidden" name="statement">
                <div class="file-loading">
                    <input class="file-upload" id="statement" name="file" type="file">
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js" />
<script th:inline="javascript">
    var prefix = ctx + "business/clue"
    $("#form-clue-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-clue-add').serialize());
        }
    }

    $("input[name='approvalTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='payTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
    var fileList = new Array();
    var fileName = new Array();
    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 20,
        autoReplace: false,
    }).on('fileuploaded', function (event, data, previewId, index) {
        fileList.push(data.response.url)
        fileName.push(data.response.name)
        $("input[name='" + event.currentTarget.id + "']").val(fileList)
        $("#"+$(this).attr("id")).val(data.response.url)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    }).on('filesuccessremove', function(event, id) {
        deleteArray(event, id);
    });
    function deleteArray(event, id){
        var name = id.split("_")[1];
        var index = fileName.indexOf(name);
        if(fileList.length > 0 && fileName.length > 0){
            fileList.splice(index,index);
            fileName.splice(index,index);
            $("input[name='" + event.currentTarget.id + "']").val(fileList)
            $("#fileName").val(fileName)
        }
    }
    $(function() {
        $('.summernote').summernote({
            lang: 'zh-CN',
            height: 194,
            callbacks: {
                onChange: function(contents, $edittable) {
                    $("input[name='" + this.id + "']").val(contents);
                },
                onImageUpload: function(files) {
                    var obj = this;
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        type: "post",
                        url: ctx + "common/upload",
                        data: data,
                        cache: false,
                        contentType: false,
                        processData: false,
                        dataType: 'json',
                        success: function(result) {
                            if (result.code == web_status.SUCCESS) {
                                $('#' + obj.id).summernote('insertImage', result.url);
                            } else {
                                $.modal.alertError(result.msg);
                            }
                        },
                        error: function(error) {
                            $.modal.alertWarning("图片上传失败。");
                        }
                    });
                }
            }
        });
    });
</script>
</body>
</html>